package com.xinhe.web.reposity;

import com.xinhe.web.entity.UserRole;
import com.xinhe.web.entity.UserRole;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;


public interface AuthUserRoleRepository extends JpaRepository<UserRole, Long> {
    @Query("from UserRole where fUserId = ?1")
    List<UserRole> findAuthUserRoleByUserid(Long fUserId);
    @Query(value = "SELECT GROUP_CONCAT(role.NAME) FROM auth_user_role aur INNER JOIN auth_role role ON aur.f_role_id = role.id WHERE aur.removed = 0 AND role.removed = 0 AND aur.f_user_id = ?1",nativeQuery = true)
    String queryRole(Long userId);
}